package com.example.dynamicdatasourcetest.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.example.dynamicdatasourcetest.datasource.DynamicDataSource;
import com.example.dynamicdatasourcetest.datasource.LoadDataSource;
import com.example.dynamicdatasourcetest.enumeration.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;


public class DataSourceConfig {

    @Autowired
    LoadDataSource loadDataSource;

    @Bean
    @ConfigurationProperties("spring.datasource.ds.master")
    public DataSource masterDataSource(){
        return DruidDataSourceBuilder.create().build();
    }

    @Bean
    @ConfigurationProperties("spring.datasource.ds.slave")
    public DataSource slaveDataSource(){
        return DruidDataSourceBuilder.create().build();
    }


}
